package com.junqson.je.admin.service;

import com.junqson.je.admin.repo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Descriptions 统计数据服务
 * @Company
 * @Author Junqson
 * @Date 2020/3/2 11:04
 * @Version 1.0
 */
@Service
public class StatisticsService {


    @Autowired
    private UserRepo userRepo;

    @Autowired
    private JobRepo jobRepo;

    @Autowired
    private ApplicationRepo applicationRepo;

    @Autowired
    private InterviewRepo interviewRepo;

    @Autowired
    private FileRepo fileRepo;

    @Autowired
    private ProblemSetRepo problemSetRepo;

    @Autowired
    private ProblemRepo problemRepo;


    /**
     * 总用户数
     *
     * 认证用户数
     *
     * 已发布的职位数目
     *
     * 已邀请的面试数
     *
     * 已投递的职位总数
     *
     * 题库数目
     *
     * 试题总数
     *
     * 文件总数
     */
    public Map<String, Long> allSumNums() {

        Map<String, Long> result = new HashMap<>();


        long allUser = userRepo.count();
        long allAuthUser = userRepo.countAllByAuthenticatedTrue();
        long allJob = jobRepo.count();
        long allApplications = applicationRepo.count();
        long allIntv = interviewRepo.count();
        long allTiku = problemSetRepo.count();
        long allProblem = problemRepo.count();
        long allFiles = fileRepo.count();

        result.put("allUser", allUser);
        result.put("allAuthUser", allAuthUser);
        result.put("allJob", allJob);
        result.put("allApplications", allApplications);
        result.put("allIntv", allIntv);
        result.put("allTiku", allTiku);
        result.put("allProblem", allProblem);
        result.put("allFiles", allFiles);

        return result;

    }
}
